home *** CD-ROM | disk | FTP | other *** search
/ MacTech 1 to 12 / MacTech-vol-1-12.toast / Source / MacTech® Magazine / Volume 11 - 1995 / 11.04 Apr 95 / TreeAppƒ / Eric's C++ Libraries / Interface Classes / CPPScrollArea.h < prev    next >
Encoding:
C/C++ Source or Header  |  1996-04-04  |  3.9 KB  |  144 lines  |  [TEXT/KAHL]

  1. /********************************************************* DEFINITION
  2.     DATE:    10/17/93
  3.     AUTHOR: Eric R. Rosé
  4.     
  5.     CLASS:  CPPScrollArea
  6.     
  7.     SUPERCLASS: CPPVisualObject
  8.     
  9.         This C++ class manages a scrollable area
  10.     
  11. ********************************************************************/
  12.  
  13.  
  14. #pragma once
  15.  
  16. #include <CPPVisualObject.h>
  17.  
  18. class CPPWindow;
  19.  
  20. class CPPScrollArea : public CPPVisualObject{
  21. public:
  22.  
  23.                     CPPScrollArea (CPPWindow *OurWindow,
  24.                                   Rect *ViewArea,
  25.                                   Rect *DestArea,
  26.                                   Boolean UseHScroll = TRUE,
  27.                                   Boolean UseVScroll = TRUE,
  28.                                   short hStep = 10, 
  29.                                   short vStep = 10);
  30.                     CPPScrollArea (CPPWindow *OurWindow,
  31.                                   Boolean UseHScroll = TRUE,
  32.                                   Boolean UseVScroll = TRUE,
  33.                                   short hStep = 10, 
  34.                                   short vStep = 10);
  35.                     ~CPPScrollArea (void);
  36.  
  37.     virtual    Boolean    Member (char *className);
  38.     virtual    char     *ClassName (void);
  39.  
  40.     virtual    Boolean    DoCommand (short commandID);
  41.  
  42.     virtual    void    DoCut (void);
  43.     virtual    void    DoCopy (void);
  44.     virtual    void    DoPaste (void);
  45.     virtual    void    DoClear (void);
  46.     virtual    void    DoSelectAll (void);
  47.  
  48.     virtual    void    Activate (Boolean nowActive);
  49.     virtual    Boolean DoClick (EventRecord *theEvent);
  50.     virtual    void    DoIdle (void);
  51.             Rect    *GetAreaRect (void);
  52.     virtual    Rect    *GetBounds (void);
  53.     
  54.             void    Draw (void);
  55.     virtual    void    DrawContents (void);
  56.     virtual    void    MakeVisible (Boolean nowVisible);
  57.     virtual    void    TargetHilite (Boolean makeTarget);
  58.                         
  59.             void    AdjustCoordinates (void);
  60.             void    RestoreCoordinates (void);
  61.  
  62.             void    Area2Local (Point *thePoint);
  63.             void    Local2Area (Point *thePoint);
  64.             void    Area2Global (Point *thePoint);
  65.             void    Global2Area (Point *thePoint);
  66.  
  67.             void    SetHorizontalStep (short stepSize);
  68.             void    SetVerticalStep    (short stepSize);
  69.  
  70.             void     MoveScrollArea (void);
  71.          
  72.              long    AreaWidth (void);
  73.              long    AreaHeight (void);
  74.              long    ViewWidth (void);
  75.              long    ViewHeight (void);
  76.  
  77.              void    AutoScroll (void);
  78.  
  79.             void    ScrollLeft (short steps);
  80.             void    ScrollRight (short steps);
  81.             void    ScrollUp (short steps);
  82.             void    ScrollDown (short steps);
  83.  
  84. protected:
  85.     Boolean            isDragging;
  86.     Boolean            needsErase;
  87.     Point            anchorPoint,
  88.                     lastPoint,
  89.                     currentPoint;
  90.     Rect            areaRect,    // the visible area in window coordinates
  91.                     destRect,    // the entire size of the area we control
  92.                     viewRect,    // the visible area in destRect coords
  93.                     selRect,    // the current selection in destRect coords
  94.                     bounds;        // temp variable used in GetBounds
  95.     ControlHandle    HScroll;
  96.     ControlHandle     VScroll;
  97.     Boolean            hasSelection;
  98.  
  99.     virtual    Boolean    DoScrollAreaClick (Point clickPt, short modifiers, Rect *selRect);
  100.     virtual    void    ResizeContent (short newWidth, short newHeight);
  101.     virtual    void    MoveContent (short newH, short newV);
  102.     
  103.             void    MakeSelection (Rect *newSelection);
  104.             void    RemoveSelection (void);
  105.     virtual    void    HiliteSelection (Boolean doHilight);
  106.     virtual    void    IdleSelection (void);
  107.     
  108. private:
  109.     short            hStep;
  110.     short            vStep;
  111.                     
  112.     RgnHandle        oldClip,
  113.                     newClip;
  114.             
  115.                     
  116.     static    CPPScrollArea    *gCurrentArea;
  117.     static    ControlHandle    gVScroll;
  118.     static    ControlHandle    gHScroll;
  119.                     
  120.     // static class methods
  121.     static pascal void Scroll_Right (ControlHandle theControl, 
  122.                                         short ctlPart);
  123.     static pascal void Scroll_Left (ControlHandle theControl, 
  124.                                         short ctlPart);
  125.     static pascal void Scroll_Up (ControlHandle theControl, 
  126.                                         short ctlPart);
  127.     static pascal void Scroll_Down (ControlHandle theControl, 
  128.                                         short ctlPart);
  129.  
  130.             void    VPageScroll (long part, long direction);
  131.             void    HPageScroll (long part, long direction);
  132.             void    AdjustScrollBar (void);
  133.             void     DoVScroller (Point clickPt, short part);
  134.             void    DoHScroller (Point clickPt, short part);
  135.  
  136.             void    MakeCPPScrollArea (CPPWindow *OurWindow, 
  137.                                        Rect *ViewArea, 
  138.                                        Rect *DestArea, 
  139.                                           Boolean UseHScroll, 
  140.                                           Boolean UseVScroll,
  141.                                           short hStep,
  142.                                           short vStep);
  143.  
  144. };